package com.lagou.logindemo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
public class LoginController {

    /**
     * 登录鉴权
     *
     * @param username 用户名
     * @param password 密码
     * @return 视图名
     */
    @RequestMapping("/login")
    public String login(String username, String password, HttpSession session) {
        if ("admin".equals(username) && "admin".equals(password)) {
            session.setAttribute("login", true);
            return "redirect:loginSuccess.html";
        }

        return "redirect:loginFail.html";
    }
}
